﻿#include "mainwindow.h"

#include <QApplication>

#include <QCamera>
#include <QMediaCaptureSession>
#include <QVideoWidget>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;

    // 在您的类中声明成员
    QCamera *camera;
    QMediaCaptureSession *captureSession;
    QVideoWidget *viewfinder;

    // 在构造函数或初始化函数中设置
    camera = new QCamera;
    captureSession = new QMediaCaptureSession;
    viewfinder = new QVideoWidget;

    // 连接组件
    captureSession->setCamera(camera);
    captureSession->setVideoOutput(viewfinder);

    // 启动相机
    camera->start();


    w.show();
    return a.exec();
}
